<?php
header('Content-Type:application/json');

@$phone = $_REQUEST['phone'];
if(empty($phone)){
    echo '[]';
    return ;
}

$conn = mysqli_connect('127.0.0.1','root','','fruit');

$sql = 'SET NAMES UTF8';
mysqli_query($conn,$sql);

$sql = "SELECT fruit_order.oid,fruit_order.order_time,fruit_order.user_name,fruit_dish.img_sm,fruit_dish.did FROM fruit_dish,fruit_order WHERE fruit_order.did=fruit_dish.did AND fruit_order.phone=$phone";

$result = mysqli_query($conn,$sql);
while(true){
    $row = mysqli_fetch_assoc($result);

    if(!$row){break;}
    $output[] = $row;
}

echo json_encode($output);

?>